package reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class Test {

    public void test() {
        System.out.println("test invoke");
    }
    public static void main(String[] args) throws InvocationTargetException, IllegalAccessException, InstantiationException, ClassNotFoundException {
        String className = "reflect.Person";
        Class clazz = Class.forName(className);
        Method[] methods = clazz.getMethods();
        Person person = (Person) clazz.newInstance();
        for (Method method : methods) {
            if (method.getModifiers() == Modifier.PUBLIC && method.getParameterCount() == 0) {
                System.out.println(method.getName());
                method.invoke(person);
            }
        }
    }
}
